import {
    init,
    classModule,
    propsModule,
    styleModule,
    eventListenersModule,
    h,
  } from "snabbdom";
  
  const patch = init([
    // Init patch function with chosen modules
    classModule, // makes it easy to toggle classes
    propsModule, // for setting properties on DOM elements
    styleModule, // handles styling on elements with support for animations
    eventListenersModule, // attaches event listeners
  ]);
  
  const container = document.getElementById("container");
  
//虚拟DOM 
// const vnode = h("h1",{},"测试文本一") //文本转成虚拟DOM
const vnode1 = h("ul",{},[
    h("li",{},'a'),
    h("li",{},'b'),
    h("li",{},'c')
])
console.log(1,vnode1)
//新老节点替换
patch(container,vnode1)


const vnode2 = h("ul",{},[
    h("li",{},'b'),
    h("li",{},'c')
])

const btn = document.getElementById("btn");
btn.onclick = function(){
    // const vnode1 = h("div",{},"测试文本二")  
    patch(vnode1,vnode2)
}